﻿// --------------------------------------------------------------------------------------
// 	文 件 名: mtStruct_WorkFlow.cs
// --------------------------------------------------------------------------------------
// 	创建时间: 2021/12/08
// 	版　　本: Version:  1.0.0
// 	版    权: Copyright (C) 2007 - 2021 NUCTECH All Rights Reserved
// 	作    者: chenyu
// --------------------------------------------------------------------------------------
// 	说    明: MTS - 数据结构定义。
// --------------------------------------------------------------------------------------
// 	修改历史:
// 			日期							改动
//		2021.12.08						  创建模块
// --------------------------------------------------------------------------------------

using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using SH;
namespace MTS
{

    //  ACCT_DEV_GUID u8"{D0458CAD-7AB4-4D22-9BDD-F7857FB1BEB8}"

    public enum emWFTaskItemType
    {
        emWFTIT_None,
        emWFTIT_Scan,   //扫描任务
        emWFTIT_Calib,  //校正任务
        emWFTIT_Rcc,    //重建任务
        emWFTIT_Rcg,    //识别任务
        emWFTIT_Rcs,    //存储任务
        emWFTIT_IPS,    //判图任务
    };

    public enum emWFTaskItemFlag
    {
        emWFF_None,         // 0,未定义
        emWFF_New,          // 1-新任务
        emWFF_Accepted,     // 2-已受理
        emWFF_Executing,    // 3-任务执行中
        emWFF_Stop,         // 4-停止
        emWFF_Error,        // 5-错误
        emWFF_Failure,      // 6-失败
        emWFF_Finish,       // 7-完成
        emWFF_Canceled,     // 8-取消，由任务管理确定是否取消。一般在扫描失败、重建失败后导致任务取消
        emWFF_NotSupport,   // 9- 不支持，执行服务不支持该任务，可能由于任务项内的某些参数不被支持
        emWFF_Skip,         // 10-忽略 ,当不需要执行该任务时，设置为跳过
        emWFF_NextStep,     // 11-任务有下一步操作，例如：性能检验有下一次扫描检验
        emWFF_FinalStep,    // 12-任务执行到最后一步，例如：性能检验最后一次扫描重建后，便开始检验
    };

    // 存储任务流：存储类型
    public enum emWFStoreType
    {
        emWFST_None = 0,
        emWFST_Trad_FS = 1,     // 传统文件系统
        emWFST_Dist_S3 = 2,     // 分布式S3
    };

    public class mtWFTaskItem : mtObject, shISerializeable
    {
        emWFTaskItemType m_emWFTaskItemType = emWFTaskItemType.emWFTIT_None;

        emWFTaskItemFlag m_emTaskFlag = emWFTaskItemFlag.emWFF_None;

        // 存储任务：1-存数据，2-取数据
        // 重建任务：1-扫描重建，2-性能检验，3-性能校正
        ulong m_nSubTaskFlag = 0;

        string m_strTaskId;    // 任务ID,目前同prn。

        ulong m_timeStart = 0;  // 任务开始处理的时间
        ulong m_timeFinish = 0; // 任务处理结束的时间（可能是正常结束、失败或被取消）

        public string TaskId { get => m_strTaskId; set => m_strTaskId = value; }
        public emWFTaskItemType TaskItemType { get => m_emWFTaskItemType; set => m_emWFTaskItemType = value; }
        public emWFTaskItemFlag TaskItemFlag { get => m_emTaskFlag; set => m_emTaskFlag = value; }
        public ulong SubTaskFlag { get => m_nSubTaskFlag; set => m_nSubTaskFlag = value; }
        public ulong TimeStart { get => m_timeStart; set => m_timeStart = value; }
        public ulong TimeFinish { get => m_timeFinish; set => m_timeFinish = value; }

        protected mtWFTaskItem()
             : base(1)
        {
        }


        protected mtWFTaskItem(emWFTaskItemType itemType)
        : base(1)
        {
            m_emWFTaskItemType = itemType;
        }



        protected mtWFTaskItem(mtWFTaskItem other)
            : base(other)
        {
            m_emWFTaskItemType = other.m_emWFTaskItemType;
            m_emTaskFlag = other.m_emTaskFlag;
            m_nSubTaskFlag = other.m_nSubTaskFlag;
            m_strTaskId = other.m_strTaskId;
            m_timeStart = other.m_timeStart;
            m_timeFinish = other.m_timeFinish;
        }

        public new shISerializer serialize(shISerializer sc)
        {
            base.serialize(sc);
            sc.serialize(ref m_emWFTaskItemType);
            sc.serialize(ref m_emTaskFlag);
            sc.serialize(ref m_nSubTaskFlag);
            sc.serialize(ref m_strTaskId);
            sc.serialize(ref m_timeStart);
            sc.serialize(ref m_timeFinish);

            return sc;
        }

        public override bool Equals(object obj)
        {
            return base.Equals(obj);
        }

        public override int GetHashCode()
        {
            return base.GetHashCode();
        }

        public override string ToString()
        {
            return base.ToString();
        }
    }

    public class mtWFScan : mtWFTaskItem, shISerializeable
    {
        uint m_nProcedureType = 0;   // 流程类型：0-未知，1-扫描，2-重新扫描，3-箱体退回，4-箱体送出

        emScanType m_scanType = emScanType.emScanType_Unknown;      // 扫描类型
        emScanDirection m_scanDirection = emScanDirection.emScanDirection_Forword;    // 扫描方向
        emCargoType m_cargoType = emCargoType.emCT_Unknown;        // 箱体类型

        uint m_nCargoId;     // 电控的自增长ID,
        string m_strEDINo;        // 电子申报信息编号,如果没有绑定，则设置为空
        emConclusion m_inspectResult = emConclusion.emSC_Unknown;   // 判图结论，给电控，用于控制通道出口处的开检指示灯

        string    m_strScanName;        // 扫描员ID

        public uint ProcedureType { get => m_nProcedureType; set => m_nProcedureType = value; }
        public emScanType ScanType { get => m_scanType; set => m_scanType = value; }
        public emScanDirection ScanDirection { get => m_scanDirection; set => m_scanDirection = value; }
        public emCargoType CargoType { get => m_cargoType; set => m_cargoType = value; }
        public uint CargoId { get => m_nCargoId; set => m_nCargoId = value; }
        public string EDINo { get => m_strEDINo; set => m_strEDINo = value; }
        public emConclusion InspectResult { get => m_inspectResult; set => m_inspectResult = value; }
        public string ScanName { get => m_strScanName; set => m_strScanName = value; }

        public mtWFScan()
        : base(emWFTaskItemType.emWFTIT_Scan)
        {

        }

        public mtWFScan(mtWFScan other)
             : base(other)
        {
            m_nProcedureType = other.m_nProcedureType;
            m_scanType = other.m_scanType;
            m_scanDirection = other.m_scanDirection;
            m_cargoType = other.m_cargoType;
            m_nCargoId = other.m_nCargoId;
            m_strEDINo = other.m_strEDINo;
            m_inspectResult = other.m_inspectResult;
            m_strScanName = other.m_strScanName;

        }


        public new shISerializer serialize(shISerializer sc)

        {
            base.serialize(sc);
            sc.serialize(ref m_nProcedureType);
            sc.serialize(ref m_scanType);
            sc.serialize(ref m_scanDirection);
            sc.serialize(ref m_cargoType);
            sc.serialize(ref m_nCargoId);
            //sc.serialize(m_nSourceNum);
            sc.serialize(ref m_strEDINo);
            sc.serialize(ref m_inspectResult);
            sc.serialize(ref m_strScanName);

            return sc;
        }
    }

    public class mtWFCalib : mtWFTaskItem, shISerializeable
    {
        uint m_nCalibCmd = 0;            // 1-开始标定流程；2-停止标定流程
        List<uint> m_vecSourceId = new List<uint>();         // 加速器Id
        List<mtDetParam> m_vecCalibParam = new List<mtDetParam>();        // 探测器参数
        string m_strCalibReport;      // 诊断报告（json）

        public uint CalibCmd { get => m_nCalibCmd; set => m_nCalibCmd = value; }
        public List<uint> SourceIds { get => m_vecSourceId; set => m_vecSourceId = value; }
        public List<mtDetParam> CalibParams { get => m_vecCalibParam; set => m_vecCalibParam = value; }
        public string CalibReport { get => m_strCalibReport; set => m_strCalibReport = value; }

        public mtWFCalib()
               : base(emWFTaskItemType.emWFTIT_Calib)


        {
        }

        public mtWFCalib(mtWFCalib other)
            : base(other)
        {
            m_nCalibCmd = other.m_nCalibCmd;

        }
        public new shISerializer serialize(shISerializer sc)

        {
            base.serialize(sc);
            sc.serialize(ref m_nCalibCmd);
            sc.serialize(ref m_vecSourceId);
            sc.serialize(m_vecCalibParam);
            sc.serialize(ref m_strCalibReport);

            return sc;
        }
    }

    /// <summary>
    /// 性能检验相关的参数
    /// </summary>
    public class mtPvParam : shISerializeable
    {
        emPerformanceVerifType m_pvType = emPerformanceVerifType.emPvType_Unknown;                // 检验或标定
        uint m_nAutoStateResult = 0;  // 统计结果：0-统计成功；其它-算法的错误码	
        int m_nFinalResult = -1;        // 扫描结束后的标定或检验结果：0-性能检验失败；1-性能检验结束，重建参数可用；2-性能检验结束,重建参数偏差过大；3-后标定成功；4-后标定失败

        public emPerformanceVerifType PvType { get => m_pvType; set => m_pvType = value; }
        public uint AutoStateResult { get => m_nAutoStateResult; set => m_nAutoStateResult = value; }
        public int FinalResult { get => m_nFinalResult; set => m_nFinalResult = value; }

        public mtPvParam()
        {
        }



        public shISerializer serialize(shISerializer sc)
        {
            sc.serialize(ref m_pvType);
            sc.serialize(ref m_nAutoStateResult);
            sc.serialize(ref m_nFinalResult);

            return sc;
        }


    }

    public class mtGWFRecon : mtWFTaskItem, shISerializeable
    {
        uint m_nSourceNum = 0;       // 加速器数量
        uint m_nScanTimes = 0;       // 扫描次数：2趟、4趟等	
        List<float> m_vecScanAngle = new List<float>();       // 扫描角度：每趟扫描的角度值
        emEnergyType m_energyType = emEnergyType.emET_Unknown;      // 扫描的能量类型
        emCargoType m_cargoType = emCargoType.emCT_Unknown;        // 箱体类型	
        bool m_bEnableCalib = false;       // 是否进行校正
        string m_strCalibAlgVer;  // 校正算法版本
        string m_strReconAlgVer;  // 重建算法版本
        uint m_nReconDataFlag = 0;   // 重建的数据类型：0x01-低能，0x02-高能，0x04-密度，0x08-原子，0x10-材料，0x20-灰度
        mtPvParam m_pvParam = new mtPvParam();            // 性能检验相关的参数

        public uint SourceNum { get => m_nSourceNum; set => m_nSourceNum = value; }
        public uint ScanTimes { get => m_nScanTimes; set => m_nScanTimes = value; }
        public List<float> ScanAngle { get => m_vecScanAngle; set => m_vecScanAngle = value; }
        public emEnergyType EnergyType { get => m_energyType; set => m_energyType = value; }
        public emCargoType CargoType { get => m_cargoType; set => m_cargoType = value; }
        public bool EnableCalib { get => m_bEnableCalib; set => m_bEnableCalib = value; }
        public string CalibAlgVer { get => m_strCalibAlgVer; set => m_strCalibAlgVer = value; }
        public string ReconAlgVer { get => m_strReconAlgVer; set => m_strReconAlgVer = value; }
        public mtPvParam PvParam { get => m_pvParam; set => m_pvParam = value; }

        public mtGWFRecon()
        : base(emWFTaskItemType.emWFTIT_Rcc)
        {
        }

        public new shISerializer serialize(shISerializer sc)

        {
            base.serialize(sc);

            sc.serialize(ref m_nSourceNum);
            sc.serialize(ref m_nScanTimes);
            sc.serialize(ref m_vecScanAngle);
            sc.serialize(ref m_energyType);
            sc.serialize(ref m_cargoType);
            sc.serialize(ref m_bEnableCalib);
            sc.serialize(ref m_strCalibAlgVer);
            sc.serialize(ref m_strReconAlgVer);
            sc.serialize(ref m_nReconDataFlag);
            sc.serialize(m_pvParam);
            return sc;
        }

    }

    // 自动识别的算法信息
    public class mtRcgAlgInfo : mtObject, shISerializeable
    {
        uint m_nSusType = 0;         // 待识别的嫌疑物类型
        string m_strAlgVersion;    // 待识别的算法版本

        public uint SusType { get => m_nSusType; set => m_nSusType = value; }
        public string AlgVersion { get => m_strAlgVersion; set => m_strAlgVersion = value; }

        public mtRcgAlgInfo()
              : base(0)


        {
        }

        public mtRcgAlgInfo(uint nSusType, string strAlgVersion)
            : base(0)
        {
            m_nSusType = nSusType;
            m_strAlgVersion = strAlgVersion;
        }

        public new shISerializer serialize(shISerializer sc)
        {
            base.serialize(sc);
            sc.serialize(ref m_nSusType);
            sc.serialize(ref m_strAlgVersion);

            return sc;
        }

    }

    public class mtGWFRecognize : mtWFTaskItem, shISerializeable
    {
        string m_strRcgTaskId;     // 识别任务ID
        List<mtRcgAlgInfo> m_vecRcgAlgInfo = new List<mtRcgAlgInfo>();    // 识别的算法集合

        public string RcgTaskId { get => m_strRcgTaskId; set => m_strRcgTaskId = value; }
        public List<mtRcgAlgInfo> RcgAlgInfos { get => m_vecRcgAlgInfo; set => m_vecRcgAlgInfo = value; }

        //需要增加是否生成map。

        public mtGWFRecognize()
        : base(emWFTaskItemType.emWFTIT_Rcg)

        {
        }



        public new shISerializer serialize(shISerializer sc)

        {
            base.serialize(sc);
            sc.serialize(ref m_strRcgTaskId);
            sc.serialize(m_vecRcgAlgInfo);

            return sc;
        }

    }

    public class mtGWFStorage : mtWFTaskItem, shISerializeable
    {
        //0x80：DR数据; 0x81：DR低能; 0x82：DR高能; 0x84：DR灰度; 0x88：DR材料;
        //0x8000：HEL数据; 0x8100：HEL低能; 0x8200：HEL高能; 0x8400：HEL密度; 0x8800：HEL原子; 0x9000：HEL材料; 0xA000：HEL灰度;
        //0x800000：嫌疑物数据;0x810000：Sus文件;0x820000：Csus文件;0x840000：Dsus文件;0x880000：Rcn3文件;0x900000：JudgeXml文件;0xC00000：未识别出Sus;
        //0x80000000：图片;0x81000000：TSP图片;0x82000000：DR彩色化图片;0x84000000：CT彩色化图片;0x88000000：3D图片;0x90000000：扫描入口拍照;
        //0x8000000000：Tsp;0x8100000000：Tsp低能;0x8200000000：Tsp高能;
        //0x800000000000：Img;0x810000000000：Img低能;0x820000000000：Img高能;0x840000000000：Img灰度;0x880000000000：Img材料;
        //0x80000000000000：原始数据;0x81000000000000：原始数据本底;0x82000000000000：原始数据空气;0x84000000000000：原始数据物体；

        ulong m_nDataTypeMask = 0;        // 需要操作的数据类型
        emWFStoreType m_storeType = emWFStoreType.emWFST_None;

        public ulong DataTypeMask { get => m_nDataTypeMask; set => m_nDataTypeMask = value; }
        public emWFStoreType StoreType { get => m_storeType; set => m_storeType = value; }

        public mtGWFStorage()
              : base(emWFTaskItemType.emWFTIT_Rcs)

        {
        }

        public new shISerializer serialize(shISerializer sc)

        {
            base.serialize(sc);
            sc.serialize(ref m_nDataTypeMask);
            sc.serialize(ref m_storeType);

            return sc;
        }

    }

    /// <summary>
    /// 查验流程信息
    /// </summary>
    public class mtInspectProcessInfo : mtObject, shISerializeable
    {
        emInspectTaskType m_inspectTaskType = emInspectTaskType.emISPT_Unknown;        // 查验类型  
        emConclusion m_procResult = emConclusion.emSC_Unknown;          // 查验结论
        uint m_nUserId = 0;              // 负责查验的用户ID
        string m_strUserName;         // 负责查验的用户名称
        ulong m_timeStart = 0;          // 查验处理开始时间
        ulong m_timeFinish = 0;         // 查验处理结束时间

        public emInspectTaskType InspectTaskType { get => m_inspectTaskType; set => m_inspectTaskType = value; }
        public emConclusion ProcResult { get => m_procResult; set => m_procResult = value; }
        public uint UserId { get => m_nUserId; set => m_nUserId = value; }
        public string UserName { get => m_strUserName; set => m_strUserName = value; }
        public ulong TimeStart { get => m_timeStart; set => m_timeStart = value; }
        public ulong TimeFinish { get => m_timeFinish; set => m_timeFinish = value; }

        public mtInspectProcessInfo()
        : base(0)


        {
        }

        public mtInspectProcessInfo(emInspectTaskType mInspectTaskType,
         emConclusion mProcResult, uint mNUserId, string mStrUserName,
                          ulong mTimeStart, ulong mTimeFinish)
        : base(0)
        {
            m_inspectTaskType = mInspectTaskType;
            m_procResult = mProcResult;
            m_nUserId = mNUserId;
            m_strUserName = mStrUserName;
            m_timeStart = mTimeStart;
            m_timeFinish = mTimeFinish;
        }




        public new shISerializer serialize(shISerializer sc)

        {
            base.serialize(sc);
            sc.serialize(ref m_inspectTaskType);
            sc.serialize(ref m_procResult);
            sc.serialize(ref m_nUserId);
            sc.serialize(ref m_strUserName);
            sc.serialize(ref m_timeStart);
            sc.serialize(ref m_timeFinish);

            return sc;
        }

    }

    public class mtGWFInspect : mtWFTaskItem, shISerializeable
    {	
        emInspectMode m_inspectMode = emInspectMode.emISPM_Unknown;	// 判图模式：自动/人工
        List<mtInspectProcessInfo> m_vecProcessInfo = new List<mtInspectProcessInfo>();

        public emInspectMode InspectMode { get => m_inspectMode; set => m_inspectMode = value; }
        public List<mtInspectProcessInfo> ProcessInfo { get => m_vecProcessInfo; set => m_vecProcessInfo = value; }

        public mtGWFInspect()
        : base(emWFTaskItemType.emWFTIT_IPS)

        {
        }



        public new shISerializer serialize(shISerializer sc)
        {
            base.serialize(sc);

            sc.serialize(m_vecProcessInfo);
            sc.serialize(ref m_inspectMode);
            return sc;
        }

    }

    public class mtGWFTask : mtObject, shISerializeable
    {
        string m_taskId;       // 任务号，暂时用PRN代替
                               //emGWFTaskType	m_taskType;

        ulong m_createTime = 0;   // 任务创建时间
        ulong m_finishTime = 0;   // 任务结束时间，指代正常完成或取消的时间

        List<mtWFTaskItem> m_listTaskItem = new List<mtWFTaskItem>();

        public string TaskID { get => m_taskId; set => m_taskId = value; }
        public ulong CreateTime { get => m_createTime; set => m_createTime = value; }
        public ulong FinishTime { get => m_finishTime; set => m_finishTime = value; }


        public List<mtWFTaskItem> ListTaskItem { get => m_listTaskItem; }

        public mtGWFTask()
        : base(0)
        {
        }

        public mtGWFTask(string taskId,ulong createTime,ulong finishTime)
:           base(0)
        {
            m_taskId = taskId;
            m_createTime = createTime; 
            m_finishTime = finishTime;
        }


        public new shISerializer serialize(shISerializer sc)

        {
            base.serialize(sc);
            sc.serialize(ref m_taskId);
            sc.serialize(ref m_createTime);
            sc.serialize(ref m_finishTime);

            long nSize = m_listTaskItem.Count;

            sc.serialize(ref nSize);

            if (sc.isRead())
            {
                clearTaskItem();
                for (var i = 0; i < nSize; ++i)
                {
                    emWFTaskItemType itemType = emWFTaskItemType.emWFTIT_None;

                    mtWFTaskItem pTaskItem = null;

                    sc.serialize(ref itemType);

                    switch (itemType)
                    {
                        case emWFTaskItemType.emWFTIT_Scan:
                            {
                                var p = new mtWFScan();
                                p.serialize(sc);
                                pTaskItem = p;
                            }
                            break;
                        case emWFTaskItemType.emWFTIT_Calib:
                            {
                                var p = new mtWFCalib();
                                p.serialize(sc);
                                pTaskItem = p;
                            }
                            break;
                        case emWFTaskItemType.emWFTIT_Rcc:
                            {
                                var p = new mtGWFRecon();
                                p.serialize(sc);
                                pTaskItem = p;
                            }
                            break;
                        case emWFTaskItemType.emWFTIT_Rcg:
                            {
                                var p = new mtGWFRecognize();
                                p.serialize(sc);
                                pTaskItem = p;
                            }
                            break;
                        case emWFTaskItemType.emWFTIT_Rcs:
                            {
                                var p = new mtGWFStorage();
                                p.serialize(sc);
                                pTaskItem = p;
                            }
                            break;
                        case emWFTaskItemType.emWFTIT_IPS:
                            {
                                var p = new mtGWFInspect();
                                p.serialize(sc);
                                pTaskItem = p;
                            }
                            break;
                        default:
                            break;
                    }

                    if (pTaskItem != null)
                        m_listTaskItem.Add(pTaskItem);
                }
            }
            else
            {
                foreach (var it in m_listTaskItem)
                {
                    var itemType = it.TaskItemType;

                    sc.serialize(ref itemType);

                    switch (itemType)
                    {
                        case emWFTaskItemType.emWFTIT_Scan:
                            {
                                mtWFScan p = (mtWFScan)(it);

                                p.serialize(sc);
                            }
                            break;
                        case emWFTaskItemType.emWFTIT_Calib:
                            {
                                mtWFCalib p = (mtWFCalib)(it);

                                p.serialize(sc);
                            }
                            break;
                        case emWFTaskItemType.emWFTIT_Rcc:
                            {
                                mtGWFRecon p = (mtGWFRecon)(it);

                                p.serialize(sc);
                            }
                            break;
                        case emWFTaskItemType.emWFTIT_Rcg:
                            {
                                mtGWFRecognize p = (mtGWFRecognize)(it);

                                p.serialize(sc);
                            }
                            break;
                        case emWFTaskItemType.emWFTIT_Rcs:
                            {
                                mtGWFStorage p = (mtGWFStorage)(it);

                                p.serialize(sc);
                            }
                            break;
                        case emWFTaskItemType.emWFTIT_IPS:
                            {
                                mtGWFInspect p = (mtGWFInspect)(it);

                                p.serialize(sc);
                            }
                            break;
                        default:
                            break;
                    }
                }
            }

            return sc;
        }

        public void addTaskItem(mtWFTaskItem pTask)
        {
            if (pTask != null)
            { m_listTaskItem.Add(pTask); }
        }

        public void clearTaskItem()
        {
            m_listTaskItem.Clear();
        }

    }
    //各分系统 汇报完成进度。
    public class mtGWFTaskProcessInfo : mtObject, shISerializeable
    {
        mtWFTaskItem m_pTaskItem = null;

        public mtWFTaskItem TaskItem { get => m_pTaskItem; 
            set {

                if (value == null)
                    return;

                if (m_pTaskItem == null)
                {
                    switch (value.TaskItemType)
                    {
                        case emWFTaskItemType.emWFTIT_Scan:
                            {

                                m_pTaskItem = value;
                            }
                            break;
                        case emWFTaskItemType.emWFTIT_Calib:
                            {
                                m_pTaskItem = value;
                            }
                            break;
                        case emWFTaskItemType.emWFTIT_Rcc:
                            {

                                m_pTaskItem = value;
                            }
                            break;
                        case emWFTaskItemType.emWFTIT_Rcg:
                            {

                                m_pTaskItem = value;
                            }
                            break;
                        case emWFTaskItemType.emWFTIT_Rcs:
                            {

                                m_pTaskItem = value;
                            }
                            break;
                        case emWFTaskItemType.emWFTIT_IPS:
                            {

                                m_pTaskItem = value;
                            }
                            break;
                        default:
                            break;
                    }
                }

            }
            
        }

        public mtGWFTaskProcessInfo()
            : base(0)

        {
        }



        public new shISerializer serialize(shISerializer sc)

        {
            base.serialize(sc);

            emWFTaskItemType taskType = emWFTaskItemType.emWFTIT_None;

            if (sc.isRead())
            {
                sc.serialize(ref taskType);

                switch (taskType)
                {
                    case emWFTaskItemType.emWFTIT_Scan:
                        {
                            var pTask = new mtWFScan();
                            pTask.serialize(sc);
                            m_pTaskItem = pTask;
                        }
                        break;
                    case emWFTaskItemType.emWFTIT_Calib:
                        {
                            var pTask = new mtWFCalib();
                            pTask.serialize(sc);
                            m_pTaskItem = pTask;
                        }
                        break;
                    case emWFTaskItemType.emWFTIT_Rcc:
                        {
                            var pTask = new mtGWFRecon();
                            pTask.serialize(sc);
                            m_pTaskItem = pTask;
                        }
                        break;
                    case emWFTaskItemType.emWFTIT_Rcg:
                        {
                            var pTask = new mtGWFRecognize();
                            pTask.serialize(sc);
                            m_pTaskItem = pTask;
                        }
                        break;
                    case emWFTaskItemType.emWFTIT_Rcs:
                        {
                            var pTask = new mtGWFStorage();
                            pTask.serialize(sc);
                            m_pTaskItem = pTask;
                        }
                        break;
                    case emWFTaskItemType.emWFTIT_IPS:
                        {
                            var pTask = new mtGWFInspect();
                            pTask.serialize(sc);
                            m_pTaskItem = pTask;
                        }
                        break;
                    default:
                        break;
                }
            }
            else
            {
                if (m_pTaskItem != null)
                {
                    taskType = m_pTaskItem.TaskItemType;

                    sc.serialize(ref taskType);

                    switch (taskType)
                    {
                        case emWFTaskItemType.emWFTIT_Scan:
                            {
                                var pTask = (mtWFScan)m_pTaskItem;
                                pTask.serialize(sc);
                            }
                            break;
                        case emWFTaskItemType.emWFTIT_Calib:
                            {
                                var pTask = (mtWFCalib)m_pTaskItem;
                                pTask.serialize(sc);
                            }
                            break;
                        case emWFTaskItemType.emWFTIT_Rcc:
                            {
                                var pTask = (mtGWFRecon)m_pTaskItem;
                                pTask.serialize(sc);
                            }
                            break;
                        case emWFTaskItemType.emWFTIT_Rcg:
                            {
                                var pTask = (mtGWFRecognize)m_pTaskItem;
                                pTask.serialize(sc);
                            }
                            break;
                        case emWFTaskItemType.emWFTIT_Rcs:
                            {
                                var pTask = (mtGWFStorage)m_pTaskItem;
                                pTask.serialize(sc);
                            }
                            break;
                        case emWFTaskItemType.emWFTIT_IPS:
                            {
                                var pTask = (mtGWFInspect)m_pTaskItem;
                                pTask.serialize(sc);
                            }
                            break;
                        default:
                            break;
                    }
                }
                else
                {
                    sc.serialize(ref taskType);
                }
            }

            return sc;
        }

    }

    /// <summary>
    /// 报警内容
    /// </summary>
    public class mtAlarmInfo :  shISerializeable
    {
        uint m_nAlarmLevel = 0;      // 报警等级 1~999: 1是最高等级
        string m_strAlarmTrigger; // 报警的触发者，可以是用户名，可以是站点名，也可以是某个硬件设备名
        ulong m_alarmTime = 0;      // 报警的时间

        emAlarmProcType m_procType = emAlarmProcType.emAPT_None;         // 处理报警的方式：// 0-未处理； 1-忽视，不处理； 2-系统自动处理； 3-用户手动处理
        string m_strProcHandler;  // 处理报警的对象
        ulong m_procTime = 0;           // 处理报警的时间
        string m_strProcDetail;   // 处理报警的描述

        // 以下内容是为高危报警临时添加，以后可能会拆出去
        string m_strAlarmPrn;     // 触发报警的图像PRN
        string m_strDetailCargoNo;    // 与PRN绑定的货物详单编号
        emCargoType m_cargoType = emCargoType.emCT_Unknown;        // 箱体类型
        string m_strCargoImgPath;   // 箱体图像相对路径

        public uint AlarmLevel { get => m_nAlarmLevel; set => m_nAlarmLevel = value; }
        public string AlarmTrigger { get => m_strAlarmTrigger; set => m_strAlarmTrigger = value; }
        public ulong AlarmTime { get => m_alarmTime; set => m_alarmTime = value; }
        public emAlarmProcType ProcType { get => m_procType; set => m_procType = value; }
        public string ProcHandler { get => m_strProcHandler; set => m_strProcHandler = value; }
        public ulong ProcTime { get => m_procTime; set => m_procTime = value; }
        public string ProcDetail { get => m_strProcDetail; set => m_strProcDetail = value; }
        public string AlarmPrn { get => m_strAlarmPrn; set => m_strAlarmPrn = value; }
        public string DetailCargoNo { get => m_strDetailCargoNo; set => m_strDetailCargoNo = value; }
        public emCargoType CargoType { get => m_cargoType; set => m_cargoType = value; }
        public string CargoImgPath { get => m_strCargoImgPath; set => m_strCargoImgPath = value; }

        public mtAlarmInfo()
               

        {
        }

        public shISerializer serialize(shISerializer sc)
        {
            sc.serialize(ref m_nAlarmLevel);
            sc.serialize(ref m_strAlarmTrigger);
            sc.serialize(ref m_alarmTime);
            sc.serialize(ref m_procType);
            sc.serialize(ref m_strProcHandler);
            sc.serialize(ref m_procTime);
            sc.serialize(ref m_procTime);
            sc.serialize(ref m_strProcDetail);
            sc.serialize(ref m_strAlarmPrn);
            sc.serialize(ref m_strDetailCargoNo);
            sc.serialize(ref m_cargoType);
            sc.serialize(ref m_strCargoImgPath);
            return sc;
        }

    }
    public class mtGSystemAlarm : mtObject, shISerializeable
    {
        // 0x0001 系统高危报警
        // 0x0002
        ulong m_nGSystemAlarm = 0;

        List<mtAlarmInfo> m_vecAlarmInfo=new List<mtAlarmInfo>();

        public ulong GSystemAlarm { get => m_nGSystemAlarm; set => m_nGSystemAlarm = value; }
        public List<mtAlarmInfo> AlarmInfos { get => m_vecAlarmInfo; }

        public mtGSystemAlarm()
            : base(0)

        {
        }


        public new shISerializer serialize(shISerializer sc)

        {
            base.serialize(sc);
            sc.serialize(ref m_nGSystemAlarm);
            sc.serialize(m_vecAlarmInfo);
            return sc;
        }

        public void AddAlarmInfo(mtAlarmInfo alarmInfo) { m_vecAlarmInfo.Add(alarmInfo); }

    }
    public class mtGRunStatusItem : mtObject, shISerializeable
    {
        emStationType stationType = emStationType.emSTT_Unknown;

        // 0x00 离线
        // 0x01 在线
        // 0x02 已登录
        // 0x8000 异常
        uint _nStatus = 0;
        protected mtGRunStatusItem(emStationType st)
             : base(1)
        {
            stationType = st;
        }


        public new shISerializer serialize(shISerializer sc)

        {
            base.serialize(sc);
            sc.serialize(ref stationType);
            sc.serialize(ref _nStatus);

            return sc;
        }

        public uint Status { get => _nStatus; set => _nStatus = value; }


        public emStationType StationType { get => stationType; set => stationType = value; }
    }

    public class mtDeviceStatus : mtObject, shISerializeable
    {
        string devClassUUID;//设备类别GUID，每种设备的uuid不同，相同设备的uuid一样

        ulong devStatus = 0;

        public mtDeviceStatus(string devClassUuid)
               : base(0)
        {
            devClassUUID = devClassUuid;
        }


        public new shISerializer serialize(shISerializer sc)

        {
            base.serialize(sc);
            sc.serialize(ref devClassUUID);
            sc.serialize(ref devStatus);
            return sc;
        }

        public string DeviceUUID { get => devClassUUID; }
    }

    public class mtACCTDeviceStatus : mtDeviceStatus, shISerializeable
    {
        string deviceSn;//设备类别GUID，每种设备的uuid不同，相同设备的uuid一样

        public mtACCTDeviceStatus()
             : base("{D0458CAD-7AB4-4D22-9BDD-F7857FB1BEB8}")

        {
        }

        public mtACCTDeviceStatus(string devSn)
        : base("{D0458CAD-7AB4-4D22-9BDD-F7857FB1BEB8}")
        {
            deviceSn = devSn;
        }


        public new shISerializer serialize(shISerializer sc)

        {
            base.serialize(sc);
            sc.serialize(ref deviceSn);

            return sc;
        }
    }

    //设备管理服务运行状态
    public class mtDMSRunStatus : mtGRunStatusItem, shISerializeable
    {
        uint m_nDeviceNum = 0;//设备通道数量

        List<mtDeviceStatus> m_listDeviceStatus = new List<mtDeviceStatus>();

        public uint DeviceNum { get => m_nDeviceNum; set => m_nDeviceNum = value; }
        public List<mtDeviceStatus> ListDeviceStatus { get => m_listDeviceStatus; }

        public mtDMSRunStatus()
            : base(emStationType.emSTT_DMS)

        { }


       
        public new shISerializer serialize(shISerializer sc)

        {
            base.serialize(sc);
            sc.serialize(ref m_nDeviceNum);

            long nSize = m_listDeviceStatus.Count;

            sc.serialize(ref nSize);

            if (sc.isRead())
            {
                clearDeviceStatus();

                for (var i = 0; i < nSize; ++i)
                {
                    string devClsUuid = "";

                    sc.serialize(ref devClsUuid);

                    if (devClsUuid == "{D0458CAD-7AB4-4D22-9BDD-F7857FB1BEB8}")
                    {
                        var p = new mtACCTDeviceStatus();

                        p.serialize(sc);

                        m_listDeviceStatus.Add(p);
                    }
                }
            }
            else
            {
                foreach (var it in m_listDeviceStatus)
                {
                    string devClsUuid = it.DeviceUUID;

                    if (devClsUuid == "{D0458CAD-7AB4-4D22-9BDD-F7857FB1BEB8}")
                    {
                        sc.serialize(ref devClsUuid);

                        mtACCTDeviceStatus p = (mtACCTDeviceStatus)(it);
                        p.serialize(sc);
                    }
                }
            }

            return sc;
        }

        public void AddDeviceStatus(mtDeviceStatus pDevStatus) { m_listDeviceStatus.Add(pDevStatus); ++m_nDeviceNum; }


        public void clearDeviceStatus()
        {
            m_listDeviceStatus.Clear();
        }

    }

    //存储的状态
    public class mtCSSSRunStatus : mtGRunStatusItem, shISerializeable
    {
        // mtStationStatus::m_status的状态值定义：bit0-数采DTS；bit1-重建DTS；bit2-识别DTS；bit3-存储DTS
        List<mtStationStatus> m_vecDetStatus = new List<mtStationStatus>(); //数采的状态
        List<mtStationStatus> m_vecRccStatus = new List<mtStationStatus>(); //重建的状态
        List<mtStationStatus> m_vecRcgStatus = new List<mtStationStatus>(); //识别的状态

        public List<mtStationStatus> DetStatus { get => m_vecDetStatus; set => m_vecDetStatus = value; }
        public List<mtStationStatus> RccStatus { get => m_vecRccStatus; set => m_vecRccStatus = value; }
        public List<mtStationStatus> RcgStatus { get => m_vecRcgStatus; set => m_vecRcgStatus = value; }

        public mtCSSSRunStatus()
             : base(emStationType.emSTT_CSS)

        {
        }

        public new shISerializer serialize(shISerializer sc)

        {
            base.serialize(sc);
            sc.serialize(m_vecDetStatus);
            sc.serialize(m_vecRccStatus);
            sc.serialize(m_vecRcgStatus);

            return sc;
        }
    };

    //重建的状态
    public class mtRCCSRunStatus : mtGRunStatusItem, shISerializeable
    {
        // mtStationStatus::m_status的状态值定义：bit0-数采DTS；bit1-重建DTS；bit2-识别DTS；bit3-存储DTS
        List<mtStationStatus> m_vecDetStatus = new List<mtStationStatus>(); //数采的状态
        List<mtStationStatus> m_vecCssStatus = new List<mtStationStatus>(); //存储的状态

        public List<mtStationStatus> DetStatus { get => m_vecDetStatus; set => m_vecDetStatus = value; }
        public List<mtStationStatus> CssStatus { get => m_vecCssStatus; set => m_vecCssStatus = value; }

        public mtRCCSRunStatus()
        : base(emStationType.emSTT_RCC)

        {
        }

        public new shISerializer serialize(shISerializer sc)

        {
            base.serialize(sc);
            sc.serialize(m_vecDetStatus);
            sc.serialize(m_vecCssStatus);
            return sc;
        }
    };

    //识别的状态
    public class mtRCGSRunStatus : mtGRunStatusItem, shISerializeable
    {
        uint nRcgNodeNum = 0;

        // mtStationStatus::m_status的状态值定义：bit0-数采DTS；bit1-重建DTS；bit2-识别DTS；bit3-存储DTS
        List<mtStationStatus> m_vecRccStatus = new List<mtStationStatus>(); //重建的状态
        List<mtStationStatus> m_vecRcgStatus = new List<mtStationStatus>(); //识别（子节点）的状态
        List<mtStationStatus> m_vecCssStatus = new List<mtStationStatus>(); //存储的状态

        public List<mtStationStatus> RccStatus { get => m_vecRccStatus; set => m_vecRccStatus = value; }
        public List<mtStationStatus> RcgStatus { get => m_vecRcgStatus; set => m_vecRcgStatus = value; }
        public List<mtStationStatus> CssStatus { get => m_vecCssStatus; set => m_vecCssStatus = value; }

        public mtRCGSRunStatus()
        : base(emStationType.emSTT_RCG)

        {
        }


        public new shISerializer serialize(shISerializer sc)

        {
            base.serialize(sc);
            sc.serialize(ref nRcgNodeNum);
            sc.serialize(m_vecRccStatus);
            sc.serialize(m_vecRcgStatus);
            sc.serialize(m_vecCssStatus);
            return sc;
        }
    };

    //判图系统的运行状态
    public class mtIPSSRunStatus : mtGRunStatusItem, shISerializeable
    {
        public mtIPSSRunStatus()
        : base(emStationType.emSTT_IPSS)

        {
        }

        public new shISerializer serialize(shISerializer sc)

        {
            base.serialize(sc);
            return sc;
        }
    };


    //扫描控制的运行状态
    public class mtSCSRunStatus : mtGRunStatusItem, shISerializeable
    {
        public mtSCSRunStatus()
        :base(emStationType.emSTT_SCS)
    {
    }
        public new shISerializer serialize(shISerializer sc)
        {
            base.serialize(sc);
            return sc;
        }
    };
    
    //判图站的运行状态
    public class mtIPS3DRunStatus : mtGRunStatusItem, shISerializeable
    {
        public mtIPS3DRunStatus()
        :base(emStationType.emSTT_IPS)
    {
    }
        public new shISerializer serialize(shISerializer sc)
        {
            base.serialize(sc);
            return sc;
        }
    };
    
    //开检站的运行状态
    public class mtCBS3DRunStatus : mtGRunStatusItem, shISerializeable
    {
        public mtCBS3DRunStatus()
        :base(emStationType.emSTT_CBS)
    {
    }
        public new shISerializer serialize(shISerializer sc)
        {
            base.serialize(sc);
            return sc;
        }
    };
    
    //确认站的运行状态
    public class mtCFS3DRunStatus : mtGRunStatusItem, shISerializeable
    {
        public mtCFS3DRunStatus()
        :base(emStationType.emSTT_CFS)
    {
    }
        public new shISerializer serialize(shISerializer sc)
        {
            base.serialize(sc);
            return sc;
        }
    };


//系统运行状态，描述整个系统综合后的一个状态
public class mtGSystemRunStatus : mtObject, shISerializeable
    {
        uint mStatus = 0;//当前系统的运行状态，从子系统归纳出的总的运行状态
        List<mtGRunStatusItem> m_listSusSystemRunStatus = new List<mtGRunStatusItem>(); //各子系统的运行状态

        public uint Status { get => mStatus; set => mStatus = value; }
        public List<mtGRunStatusItem> SusSystemRunStatusList { get => m_listSusSystemRunStatus; set => m_listSusSystemRunStatus = value; }

        public mtGSystemRunStatus()
        : base(1)

        {
        }

        public void clearRunStatusItem()
        {

            m_listSusSystemRunStatus.Clear();
            mStatus = 0;
        }

        //public void AddRunStatusItem(mtGRunStatusItem pItem) { m_listSusSystemRunStatus.Add(pItem); }

        //public void SetRunStatusList(List<mtGRunStatusItem> listStatus) { m_listSusSystemRunStatus = listStatus; }
        //public List<mtGRunStatusItem> GetRunStatusList() { return m_listSusSystemRunStatus; }


        public new shISerializer serialize(shISerializer sc)

        {
            base.serialize(sc);

            sc.serialize(ref mStatus);

            long nSize = m_listSusSystemRunStatus.Count;

            sc.serialize(ref nSize);

            if (sc.isRead())
            {
                emStationType stationType = emStationType.emSTT_Unknown;

                for (var i = 0; i < nSize; ++i)
                {
                    sc.serialize(ref stationType);

                    switch (stationType)
                    {
                        case emStationType.emSTT_RCC:
                            {
                                var p = new mtRCCSRunStatus();
                                p.serialize(sc);
                                m_listSusSystemRunStatus.Add(p);
                            }
                            break;
                        case emStationType.emSTT_RCG:
                            {
                                var p = new mtRCGSRunStatus();
                                p.serialize(sc);
                                m_listSusSystemRunStatus.Add(p);
                            }
                            break;
                        case emStationType.emSTT_CSS:
                            {
                                var p = new mtCSSSRunStatus();
                                p.serialize(sc);
                                m_listSusSystemRunStatus.Add(p);
                            }
                            break;
                        case emStationType.emSTT_IPSS:
                            {
                                var p = new mtIPSSRunStatus();
                                p.serialize(sc);
                                m_listSusSystemRunStatus.Add(p);
                            }
                            break;
                        case emStationType.emSTT_DMS:
                            {
                                var p = new mtDMSRunStatus();
                                p.serialize(sc);
                                m_listSusSystemRunStatus.Add(p);
                            }
                            break;
                        case emStationType.emSTT_SCS:
                            {
                                var p = new mtSCSRunStatus();
                                p.serialize(sc);
                                m_listSusSystemRunStatus.Add(p);
                            }
                            break;
                        case emStationType.emSTT_IPS:
                            {
                                var p = new mtIPS3DRunStatus();
                                p.serialize(sc);
                                m_listSusSystemRunStatus.Add(p);
                            }
                            break;
                        case emStationType.emSTT_CBS:
                            {
                                var p = new mtCBS3DRunStatus();
                                p.serialize(sc);
                                m_listSusSystemRunStatus.Add(p);
                            }
                            break;
                        case emStationType.emSTT_CFS:
                            {
                                var p = new mtCFS3DRunStatus();
                                p.serialize(sc);
                                m_listSusSystemRunStatus.Add(p);
                            }
                            break;
                        default:
                            break;
                    }
                }
            }
            else
            {
                foreach (var it in m_listSusSystemRunStatus)
                {
                    emStationType stationType = it.StationType;

                    sc.serialize(ref stationType);

                    switch (stationType)
                    {
                        case emStationType.emSTT_RCC:
                            {
                                mtRCCSRunStatus p = (mtRCCSRunStatus)(it);
                                p.serialize(sc);
                            }
                            break;
                        case emStationType.emSTT_RCG:
                            {
                                mtRCGSRunStatus p = (mtRCGSRunStatus)(it);
                                p.serialize(sc);
                            }
                            break;
                        case emStationType.emSTT_CSS:
                            {
                                mtCSSSRunStatus p = (mtCSSSRunStatus)(it);
                                p.serialize(sc);
                            }
                            break;
                        case emStationType.emSTT_IPSS:
                            {
                                mtIPSSRunStatus p = (mtIPSSRunStatus)(it);
                                p.serialize(sc);
                            }
                            break;
                        case emStationType.emSTT_DMS:
                            {
                                mtDMSRunStatus p = (mtDMSRunStatus)(it);
                                p.serialize(sc);
                            }
                            break;
                        case emStationType.emSTT_SCS:
                            {
                                mtSCSRunStatus p = (mtSCSRunStatus)(it);
                                p.serialize(sc);
                            }
                            break;
                        case emStationType.emSTT_IPS:
                            {
                                mtIPS3DRunStatus p = (mtIPS3DRunStatus)(it);
                                p.serialize(sc);
                            }
                            break;
                        case emStationType.emSTT_CBS:
                            {
                                mtCBS3DRunStatus p = (mtCBS3DRunStatus)(it);
                                p.serialize(sc);
                            }
                            break;
                        case emStationType.emSTT_CFS:
                            {
                                mtCFS3DRunStatus p = (mtCFS3DRunStatus)(it);
                                p.serialize(sc);
                            }
                            break;
                        default:
                            break;
                    }
                }
            }

            return sc;
        }
    }
    public class mtGSystemStatus : mtObject, shISerializeable
    {
        mtGSystemAlarm m_systemAlarm = new mtGSystemAlarm();
        mtGSystemRunStatus m_systemRunStatus = new mtGSystemRunStatus();

        public mtGSystemAlarm SystemAlarm { get => m_systemAlarm; set => m_systemAlarm = value; }
        public mtGSystemRunStatus SystemRunStatus { get => m_systemRunStatus; set => m_systemRunStatus = value; }

        public   mtGSystemStatus()
            : base(1)

        {
        }

        public new shISerializer serialize(shISerializer sc)

        {
            base.serialize(sc);
            sc.serialize(m_systemAlarm);
            sc.serialize(m_systemRunStatus);
            return sc;
        }


    }
    public class mtGStationRunStatusInfo : mtObject, shISerializeable
    {
        mtGRunStatusItem m_pRunStatusItem ;
        List<mtAlarmInfo> m_vecAlarmInfos=new List<mtAlarmInfo>();

        public mtGRunStatusItem RunStatusItem { get => m_pRunStatusItem;

            set {
                if (value == null)
                    return;

                switch (value.StationType)
                {
                    case emStationType.emSTT_RCC:
                        {
                            m_pRunStatusItem = value;
                        }
                        break;
                    case emStationType.emSTT_RCG:
                        {

                            m_pRunStatusItem = value;
                        }
                        break;
                    case emStationType.emSTT_CSS:
                        {

                            m_pRunStatusItem = value;
                        }
                        break;
                    case emStationType.emSTT_IPSS:
                        {

                            m_pRunStatusItem = value;
                        }
                        break;
                    case emStationType.emSTT_DMS:
                        {

                            m_pRunStatusItem = value;
                        }
                        break;
                    case emStationType.emSTT_SCS:
                        {
                            m_pRunStatusItem = value;
                        }
                        break;
                    case emStationType.emSTT_IPS:
                        {
                            m_pRunStatusItem = value;
                        }
                        break;
                    case emStationType.emSTT_CBS:
                        {
                            m_pRunStatusItem = value;
                        }
                        break;
                    case emStationType.emSTT_CFS:
                        {
                            m_pRunStatusItem = value;
                        }
                        break;
                    default:
                        break;
                }
            } 
        }

        public List<mtAlarmInfo> AlarmInfos { get => m_vecAlarmInfos; set => m_vecAlarmInfos = value; }

        public mtGStationRunStatusInfo()
               : base(1)


        {
        }



        public new shISerializer serialize(shISerializer sc)

        {
            base.serialize(sc);

            emStationType stationType = emStationType.emSTT_Unknown;

            if (sc.isRead())
            {
                sc.serialize(ref stationType);

                switch (stationType)
                {
                    case emStationType.emSTT_RCC:
                        {
                            var p = new mtRCCSRunStatus();
                            p.serialize(sc);
                            m_pRunStatusItem = p;
                        }
                        break;
                    case emStationType.emSTT_RCG:
                        {
                            var p = new mtRCGSRunStatus();
                            p.serialize(sc);
                            m_pRunStatusItem = p;
                        }
                        break;
                    case emStationType.emSTT_CSS:
                        {
                            var p = new mtCSSSRunStatus();
                            p.serialize(sc);
                            m_pRunStatusItem = p;
                        }
                        break;
                    case emStationType.emSTT_IPSS:
                        {
                            var p = new mtIPSSRunStatus();
                            p.serialize(sc);
                            m_pRunStatusItem = p;
                        }
                        break;
                    case emStationType.emSTT_DMS:
                        {
                            var p = new mtDMSRunStatus();
                            p.serialize(sc);
                            m_pRunStatusItem = p;
                        }
                        break;
                    case emStationType.emSTT_SCS:
                        {
                            var p = new mtSCSRunStatus();
                            p.serialize(sc);
                            m_pRunStatusItem = p;
                        }
                        break;
                    case emStationType.emSTT_IPS:
                        {
                            var p = new mtIPS3DRunStatus();
                            p.serialize(sc);
                            m_pRunStatusItem = p;
                        }
                        break;
                    case emStationType.emSTT_CBS:
                        {
                            var p = new mtCBS3DRunStatus();
                            p.serialize(sc);
                            m_pRunStatusItem = p;
                        }
                        break;
                    case emStationType.emSTT_CFS:
                        {
                            var p = new mtCFS3DRunStatus();
                            p.serialize(sc);
                            m_pRunStatusItem = p;
                        }
                        break;
                    default:
                        break;
                }
            }
            else
            {
                if (m_pRunStatusItem != null)
                {
                    stationType = m_pRunStatusItem.StationType;

                    sc.serialize(ref stationType);

                    switch (stationType)
                    {
                        case emStationType.emSTT_RCC:
                            {
                                mtRCCSRunStatus p = (mtRCCSRunStatus)(m_pRunStatusItem);
                                p.serialize(sc);
                            }
                            break;
                        case emStationType.emSTT_RCG:
                            {
                                mtRCGSRunStatus p = (mtRCGSRunStatus)(m_pRunStatusItem);
                                p.serialize(sc);
                            }
                            break;
                        case emStationType.emSTT_CSS:
                            {
                                mtCSSSRunStatus p = (mtCSSSRunStatus)(m_pRunStatusItem);
                                p.serialize(sc);
                            }
                            break;
                        case emStationType.emSTT_IPSS:
                            {
                                mtIPSSRunStatus p = (mtIPSSRunStatus)(m_pRunStatusItem);
                                p.serialize(sc);
                            }
                            break;
                        case emStationType.emSTT_DMS:
                            {
                                mtDMSRunStatus p = (mtDMSRunStatus)(m_pRunStatusItem);
                                p.serialize(sc);
                            }
                            break;
                        case emStationType.emSTT_SCS:
                            {
                                mtSCSRunStatus p = (mtSCSRunStatus)(m_pRunStatusItem);
                                p.serialize(sc);
                            }
                            break;
                        case emStationType.emSTT_IPS:
                            {
                                mtIPS3DRunStatus p = (mtIPS3DRunStatus)(m_pRunStatusItem);
                                p.serialize(sc);
                            }
                            break;
                        case emStationType.emSTT_CBS:
                            {
                                mtCBS3DRunStatus p = (mtCBS3DRunStatus)(m_pRunStatusItem);
                                p.serialize(sc);
                            }
                            break;
                        case emStationType.emSTT_CFS:
                            {
                                mtCFS3DRunStatus p = (mtCFS3DRunStatus)(m_pRunStatusItem);
                                p.serialize(sc);
                            }
                            break;
                        default:
                            break;
                    }
                }
                else
                {
                    stationType = emStationType.emSTT_Unknown;
                    sc.serialize(ref stationType);
                }
            }

            sc.serialize(m_vecAlarmInfos);

            return sc;
        }


        public void AddAlarmInfo( mtAlarmInfo alarmInfo)
        { 
            m_vecAlarmInfos.Add(alarmInfo);
        }

    }

}
